const {ccclass, property} = cc._decorator;

const viewIndex = {
    Mine: 0,
    UInfo: 1,
}
@ccclass
export default class Mine extends cc.Component {
    @property(cc.Button)
    btnBack: cc.Button = null;

    @property([cc.Node])
    viewList: cc.Node[] = [];

    showIndex: number = viewIndex.Mine;

    onEnable(){
        this.showView(viewIndex.Mine);
    }

    onBtnBack(){
        this.showView(viewIndex.Mine);
    }

    showView(index: number){
        for(let i = 0; i < this.viewList.length; ++i){
            let view = this.viewList[i];
            view.active = false;
            view.active = i == index;
        }
        this.btnBack.node.active = index == viewIndex.UInfo;
    }

    onClose(){
        this.node.active = false;
    }

    onItemClick(e: cc.Event, data: string){
        this.showView(Number(data));
    }

    onFlush(){
        this.showView(this.showIndex);
    }
}
